package fr.nts.framework.core.commun.tool;

import java.math.BigInteger;
import java.security.SecureRandom;

public class PasswordUtil{

	public static enum Difficulty{
		EASY_PASSWORD(30),
		MEDIUM_PASSWORD(60),
		HARD_PASSWORD(90);
		
		private int complexity;
		
		private Difficulty(int complexity){
			this.complexity = complexity;
		}

		// Getter/setter
		public int getComplexity(){
			return complexity;
		}

		public void setComplexity(int complexity){
			this.complexity = complexity;
		}
	}
	
	
	/**
	 * Génère un mot de passe.
	 * 
	 * @param difficulty La complexité souhaité du mot de passe.
	 * 
	 * @return Le mot de passe
	 */
	public static String generateNewPassword(Difficulty difficulty){
		SecureRandom random = new SecureRandom();
		BigInteger integer = new BigInteger(difficulty.getComplexity(), 
				                            random);

		String str = integer.toString(32);
		
		return str;
	}
}